define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'channel/agentchannelcz/index',
                    table: 't_stat_daily_openinstall_channel',
                },
                commonSearch: true,
                searchFormVisible: true,
                visible: false,
                showToggle: false,
                showColumns: false,
                search:false,
                showExport: true,
            });

            var table = $("#table");
            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                columns: [
                    [
                        {field: 'user_profile_id', title: __('用户ID')},
                        {field: 'nick_name', title: __('用户昵称'),operate: 'LIKE',},
                        {field: 'avatar', title: __('头像'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image},
                        {field: 'total_amount', title: __('充值金额'), operate: false},
                        {field: 'online', title: __('在线状态'), searchList: {'0' : '离线','1' :'在线'}, formatter: Table.api.formatter.normal},
                        {field: 'user_status', title: __('用户状态'), searchList: {'0' : '正常','1' :'冻结','2':'注销'}, formatter: Table.api.formatter.normal},
                        {field: 'role', title: __('实名认证'), searchList: {'1' : '未认证','2' :'已认证'}, formatter: Table.api.formatter.normal},
                        {field: 'finished_at', title: __('支付时间'), operate: false},
                        {field: 'channel', title: __('渠道'),searchList:channel, formatter: Table.api.formatter.normal},
                    ]
                ]
            });
            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});